#ifndef __PACKET_H__
#define __PACKET_H__

#pragma pack(1)

#define MAC_HEADER_LEN			14
#define ICMP_HEADER_LEN				4
#define IP_HEADER_LEN				20
#define TCP_HEADER_LEN				20
#define UDP_HEADER_LEN				8
#define DNS_HEADER_LEN				12

#define PSD_HEADER_LEN				12
#define QUERY_HEADER_LEN			4
#define RESPONSE_HEADER_LEN			16

#define IP_HEADER_FLAG_LEN			23

#define ETHER_IP_HEADER_LEN			34
#define ETHER_IP_TCP_HEADER_LEN		54
#define ETHER_IP_UDP_HEADER_LEN		42
#define IP_TCP_HEADER_LEN			40
#define TCP_PSD_HEADER_LEN			32
#define UDP_PSD_HEADER_LEN			20
#define UDP_DNS_PSD_HEADER_LEN		32
#define QUERY_RESPONSE_HEADER_LEN	20
#define IP_UDP_DNS_HEADER_LEN		40
#define UDP_DNS_PSD_QUERY_HEADER_LEN			36
#define UDP_DNS_PSD_QUERY_RESPONSE_HEADER_LEN	52
#define IP_UDP_DNS_QUERY_RESPONSE_HEADER_LEN	60


struct MAC_HEADER
{
	unsigned char dstAddr[6];
	unsigned char srcAddr[6];
	unsigned char type[2];
};

struct IP_HEADER
{
	unsigned char h_verlen;  
	unsigned char tos;    
	unsigned short int total_len;  
	unsigned short int ident;  
	unsigned short int frag_and_flags; 
	unsigned char  ttl;   
	unsigned char proto;  
	unsigned short int checksum; 
	unsigned long srcIP;  
	unsigned long dstIP; 
};

struct ARP_HEADER
{
	unsigned short int  hardware_type;
	unsigned short int  pro_type;
	unsigned char   hardware_addr_len;
	unsigned char   pro_addr_len;
	unsigned short int  arp_opt;
	unsigned char   src_mac[6];
	unsigned long	 src_ip;
	unsigned char   des_mac[6];
	unsigned long   des_ip;
};

struct RARP_HEADER
{
	unsigned short int  hardware_type;
	unsigned short int  pro_type;
	unsigned char   hardware_addr_len;
	unsigned char   pro_addr_len;
	unsigned short int  arp_opt;
	unsigned char   src_mac[6];
	unsigned long	 src_ip;
	unsigned char   des_mac[6];
	unsigned long   des_ip;
};

struct TCP_HEADER    
{
	unsigned short int th_sport;    
	unsigned short int th_dport;    
	unsigned long th_seq;		
	unsigned long th_ack;		
	unsigned char th_lenres;  
	unsigned char th_flag;   
	unsigned short int th_win;    
	unsigned short int th_sum;    
	unsigned short int th_urp;    
};

struct UDP_HEADER    
{
	unsigned short int th_sport;   
	unsigned short int th_dport;   
   	unsigned short int th_length;
	unsigned short int th_sum;     

};
#include <time.h> 

struct TCP_PACKET
{
	unsigned char *pFrame;
	unsigned int nPktLen;
	struct MAC_HEADER * pMacHdr;
	struct IP_HEADER * pIpHdr;
	struct TCP_HEADER * pTcpHdr;
	char * pTcpData;
	unsigned int nTcpDataLen;
	unsigned long lSIP;
	unsigned long lDIP;
	unsigned int nSPort;
	unsigned int nDPort;
	char srcMAC[20];
	char desMAC[20];
	char srcIP[20];
	char desIP[20];
	unsigned long nAck;
	unsigned long nSeq;
	unsigned long nNextSeq;
	unsigned long nFlag;
	time_t time;
};

struct UDP_PACKET
{
	unsigned char *pFrame;
	unsigned int nPktLen;
	struct MAC_HEADER * pMacHdr;
	struct IP_HEADER * pIpHdr;
	struct UDP_HEADER * pUdpHdr;
	unsigned  int nUdpDataLen;
	char *pUdpData;
	unsigned long lSIP;
	unsigned long lDIP;
	unsigned  int nSPort;
	unsigned  int nDPort;
	char srcMAC[20];
	char desMAC[20];
	char srcIP[20];
	char desIP[20];
};

typedef struct _Psd {
	unsigned long	saddr;
	unsigned long	daddr;
	char			mbz;
	char			ptcl;
	unsigned short	tcpl;
}PSD,*PPSD;


#pragma pack()

#endif
